from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = webdriver.Chrome()
browser.get('https://www.baidu.com')
wait = WebDriverWait(driver=browser, timeout=5, poll_frequency=0.5)
try:
    search_box = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'input#kw')))
    print('定位到搜索框')
except:
    print('等待超时')
finally:
    browser.quit()
